package com.zzyl.controller.manager;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.BedDto;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(path = "/bed")
public class BedController {

    @Autowired
    private BedService bedService;

    /**
     * 新增床位
     *
     * @param bedDto
     * @return
     */
    @PostMapping(path = "/create")
    public ResponseResult<Void> create(@RequestBody BedDto bedDto) {
        bedService.addBed(bedDto);
        return ResponseResult.success();
    }

    /**
     * 根据id查询床位详情
     *
     * @param id
     * @return
     */
    @GetMapping(path = "/read/{id}")
    public ResponseResult<BedVo> findBedById(@PathVariable("id") Long id) {
        BedVo bedVo = bedService.findBedById(id);
        return ResponseResult.success(bedVo);
    }

    /**
     * 修改床位信息
     *
     * @param bedDto
     * @return
     */
    @PutMapping(path = "/update")
    public ResponseResult<Void> modifyBed(@RequestBody BedDto bedDto) {
        bedService.modifyBed(bedDto);
        return ResponseResult.success();
    }

    /**
     * 删除床位
     *
     * @param id
     * @return
     */
    @DeleteMapping(path = "/delete/{id}")
    public ResponseResult<Void> removeBed(@PathVariable("id") Long id) {
        bedService.removeBed(id);
        return ResponseResult.success();
    }

}
